#include"outputfilestream.h"
#include<errno.h>
#include<fcntl.h>
#include<iostream>
#include<cstring>

void outputfilestream::create(const char* fileName)
{
	this->fp = fopen(fileName, "w+");
	if(this->fp == NULL)
		std::cout << "Error opening stream: " << strerror( errno ) << std::endl;
}

void outputfilestream::close_s()
{
	int ret = fclose(this->fp);
	if(ret < 0)
		std::cout << "Error closing stream: " << strerror( errno ) << std::endl;
}

void outputfilestream::write_s(int data)
{
	if(fwrite(&data, 1, sizeof(int), this->fp) != sizeof(int))
		std::cout << "Error writing to stream: " << strerror( errno ) << std::endl;
}
